trigger createSuggestionsComplaints on Case (after insert) {
    
    return; //for testing
    
    Set<String> caseLicense = new Set<String>();
    List<Account> accountList = new List<Account>();    
    List<Suggestion_and_Complaints__c> suggestionToInsert = new List<Suggestion_and_Complaints__c>();
    Map<String, Id> companyMap = new Map<String, Id>();
    
    Map<String, decimal> slaHoursMap = new Map<String, decimal>();
    List<SLA__c> slaList = new List<SLA__c>();
    
    for(Case cas: Trigger.new) 
    {
        if(cas.License_Number__c != null)
            caseLicense.add(cas.License_Number__c);
    }
    
    
    
    if(caseLicense.size() > 0)
    {
        accountList = new List<Account>([Select Id, Name, licenseNumber__r.Name from Account where LicenseNumber__r.Name in: caseLicense]);
    
        if(accountList.size() > 0 )
        {
            for(Account a : accountList)
            {
                companyMap.put(a.LicenseNumber__r.Name, a.Id);
            } 
        }
    }          
            /*//For SLA Hours...
            for(SLA_Custom_Setting__c slaRecord : SLA_Custom_Setting__c.getAll().values())
            {
                if(slaRecord.Process_Type__c == 'Case')
                {
                    slaHoursMap.put(slaRecord.Application_Type__c, slaRecord.SLA_Hours__c );
                }
                                        
            }*/
        
            for(Case cse : Trigger.new) 
            {
                system.debug('show me the values of ' + cse);
                Suggestion_and_Complaints__c sc = new Suggestion_and_Complaints__c();
                sc.Origin__c = cse.Origin;
                sc.Case_Number__c = cse.CaseNumber;   
                sc.Type__c = cse.Type;
                sc.Name__c = cse.SuppliedName;
                sc.License_Number__c = cse.License_Number__c;
                sc.Employee_Name__c = cse.ContactId;
                
                if(cse.License_Number__c != null && accountList.size() > 0) 
                {
                    system.debug(companyMap.get(cse.License_Number__c));
                    sc.Company__c = companyMap.get(cse.License_Number__c);
                }        
                
                sc.Mobile_Number__c = cse.SuppliedPhone;
                sc.Email__c = cse.SuppliedEmail;
                sc.Subject__c = cse.Subject;
                sc.Description__c = cse.Description;
                
                if(cse.Complain_Classification__c != null)
                    sc.Complain_Classification__c = cse.Complain_Classification__c;
                if(cse.Kind_of_Services__c != null)
                    sc.Kind_of_Services__c = cse.Kind_of_Services__c;   

                if(cse.language__c != null)
                sc.language__c = cse.language__c;    
                    

                    
                suggestionToInsert.add(sc); 
                
                
                
                
            }
            
            if(suggestionToInsert.size() > 0)
            {      
                insert(suggestionToInsert);
                
                /*// Assumes the BSC work hours are the default for the Org
                List<BusinessHours> businessHoursObjectList = new List<BusinessHours>([select id from businesshours where isDefault = true LIMIT 1]) ;
    
                if(businessHoursObjectList.size() > 0)
                {
                    //For Creating the Suggestion & Complain SLA ...
                    for(Suggestion_and_Complaints__c scObject : suggestionToInsert )
                    {
                        
                        if(slaHoursMap.get(scObject.Type__c) != null)
                        {
                            SLA__c slaObject = new SLA__c();
                            slaObject.SLA_Hours__c = slaHoursMap.get(scObject.Type__c);
                            slaObject.Actual_Start_Date_Time__c = DateTime.Now();
                           
                            // BSC works 11.5 hours / day (8:00 AM - 7:30 PM, M-F). Our SLA is 2-days (23 business hours)
                            System.debug('The Actual Start Time => '+ slaObject.Actual_Start_Date_Time__c );
                            System.debug('The Expected End Date => '+ slaObject.Actual_Start_Date_Time__c.addhours(integer.valueof(slaHoursMap.get(scObject.Type__c))));
                            System.debug('The Business Hour Date => ' + BusinessHours.add(businessHoursObjectList[0].id, slaObject.Actual_Start_Date_Time__c, integer.valueof(slaHoursMap.get(scObject.Type__c)) * 60 * 60 * 1000L));
                            System.debug('The Business Hour Date GMT => ' + BusinessHours.addGmt(businessHoursObjectList[0].id, slaObject.Actual_Start_Date_Time__c, integer.valueof(slaHoursMap.get(scObject.Type__c)) * 60 * 60 * 1000L));
                            slaObject.Expected_End_Date__c = BusinessHours.addGmt(businessHoursObjectList[0].id, slaObject.Actual_Start_Date_Time__c, integer.valueof(slaHoursMap.get(scObject.Type__c)) * 60 * 60 * 1000L); 
                            slaObject.Suggestion_and_Complaint__c = scObject.Id ;
                            slaObject.Process_Type__c = scObject.Type__c;
                            slaObject.Application_Type__c = 'Case';
                            //Adding in the List...
                            slaList.add(slaObject);
                        
                        }
                        
                    
                        
                    }
                    
                    //Now Upsert the List...
                    if(slaList.size() > 0)
                        upsert slaList;
                }*/
            }
     
    
}